package com.lagou;

import com.lagou.bean.TestServiceImpl;
import com.lagou.util.calculateTask;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.Timer;


public class AnnotationConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        //每5秒计算一次TP90,TP99
        Timer timer = new Timer();
        timer.schedule(new calculateTask(), 0,5*1000);

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        TestServiceImpl service = context.getBean(TestServiceImpl.class);
        while (true) {
            for(int i=0;i<2000;i++){
                Thread.sleep(5);
                new Thread(() -> service.test()).run();
            }
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    //@EnableDubbo(scanBasePackages = "com.lagou.bean")
    @ComponentScan("com.lagou.bean")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
